From 9c5f7509f48f4785ba6629534863b5f3f5e3ddf2 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 24 May 2011 18:24:05 +0100 Subject: [PATCH] tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment Enables direct loading of e.g. seabios.elf. Signed-off-by: Ian Campbell Committed-by: Ian Jackson --- tools/libxc/xc_hvm_build.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c index 9fe91fd86c..c32be4e91c 100644 --- a/tools/libxc/xc_hvm_build.c +++ b/tools/libxc/xc_hvm_build.c @@ -88,7 +88,9 @@ static int loadelfimage( struct elf_binary *elf, uint32_t dom, unsigned long *parray) { privcmd_mmap_entry_t *entries = NULL; - size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT; + unsigned long pfn_start = elf->pstart >> PAGE_SHIFT; + unsigned long pfn_end = (elf->pend + PAGE_SIZE - 1) >> PAGE_SHIFT; + size_t pages = pfn_end - pfn_start; int i, rc = -1; /* Map address space for initial elf image. */ @@ -105,6 +107,8 @@ static int loadelfimage( if ( elf->dest == NULL ) goto err; + elf->dest += elf->pstart & (PAGE_SIZE - 1); + /* Load the initial elf image. */ elf_load_binary(elf); rc = 0; @@ -172,12 +176,6 @@ static int setup_guest(xc_interface *xch, goto error_out; } - if ( (elf.pstart & (PAGE_SIZE - 1)) != 0 ) - { - PERROR("Guest OS must load to a page boundary."); - goto error_out; - } - IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n" " Loader: %016"PRIx64"->%016"PRIx64"\n" " TOTAL: %016"PRIx64"->%016"PRIx64"\n" -- 2.30.2